import apiService from "@service/index";

export const searchApiService = apiService.injectEndpoints({
    endpoints: (builder) => ({
        // 搜索-联想建议
        requestSuggestion: builder.query<SuggestionResponse, string>({
            query: (key) => ({ url: "/suggestion", params: { q: key } }),
        }),
        // 搜索-获取搜索结果
        requestSearchResult: builder.query<
            SearchResultResponse,
            { page: number; per_page: number; q: string }
        >({
            query: (params) => ({ url: "/search", params }),
        }),
    }),
});

export const { useLazyRequestSuggestionQuery, useLazyRequestSearchResultQuery } = searchApiService;